using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using OpenNETCF.Telephony;

namespace StructValidator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Application.DoEvents();
            AddString("Starting validation");
            
            Type[] allTypes = typeof (Call).Assembly.GetTypes();
            foreach (Type t in allTypes)
            {
                if (!t.IsValueType || t.IsPrimitive)
                    continue;
                AddString("Validating " + t.Name);
                try
                {
                    int size = Marshal.SizeOf(t);
                    AddString("Passed. Size is " + size.ToString());
                }
                catch (Exception)
                {
                    AddString("Failed");
                }
            }
        }

        private void AddString(string s)
        {
            listBox1.SelectedIndex = listBox1.Items.Add(s);
            listBox1.Update();
        }
    }
}